//
//  WBNavigationCotroller.swift
//  weibo-swift
//
//  Created by carmne on 2019/1/3.
//  Copyright © 2019 lessismore. All rights reserved.
//

import UIKit

class WBNavigationCotroller: UINavigationController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
 
    }

    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        if childViewControllers.count > 0 {
            viewController.hidesBottomBarWhenPushed = true

            viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(image: UIImage(named: "BACK_BUTTON")?.withRenderingMode(.alwaysOriginal), style: .plain, target: self, action: #selector(popToParent))

            //            viewController.na
            //            if let vc = viewController as? WBBaseViewController {
            //                var title = "返回"
            //
            //                if childViewControllers.count == 1 {
            //                    title = childViewControllers.first?.title ?? "返回"
            //                }
            //                vc.navigationItem.leftBarButtonItem = UIBarButtonItem(title: title, style: .plain, target:self , action: #selector(popToParent))
            //            }
        }

        super.pushViewController(viewController, animated: true)
    }

    @objc private func popToParent () {
        popViewController(animated: true)
    }
}
extension WBNavigationCotroller {


    }


